# -*- encoding=utf8 -*-
__author__ = "Simon"

# import time
# import sys,os
# BASE_DIR = os.path.realpath(__file__)
# print(BASE_DIR)
# sys.path.append(BASE_DIR)
from airtest.core.api import *
# import sys
# sys.path.append(r"I:\学习相关\python\自动化学习\pcr_py")
# ST.PROJECT_ROOT = "/python/自动化学习/pcr_py"

# from resolution.resolution import login
# using("guild.air")
# from guild1 import guild2

# from airtest.cli.parser import cli_setup

# if not cli_setup():
#     auto_setup(__file__, logdir=True, devices=[
#             "Android://127.0.0.1:5037/127.0.0.1:21513?cap_method=JAVACAP&&ori_method=ADBORI&&touch_method=ADBTOUCH",
#     ], project_root="I:/学习相关/python/自动化学习")


# script content
# print("start...")


# generate html report
# from airtest.report.report import simple_report
# simple_report(__file__, logpath=True)

#OK
def cilck_blue_ok():
    touch(Template(r"../blue_ok.png",threshold=0.6))

def cilck_white_ok():
    touch(Template(r"../white_ok.png",threshold=0.4))

#添加扫荡券
def add_tick(x,y,num):
    touch([0.915*x,0.615*y],times=num)
    
#使用扫荡券
def use_tick(x,y):
    touch([0.767*x,0.615*y])
    
#取消
def cancel():
    touch(Template(r"../cancel.png",threshold=0.6))

#关闭
def close():
    touch(Template(r"../close.png",threshold=0.4))

#挑战
# def battle():
#     touch(Template(r"../battle.png"))

#自定义sleep
# def custom_sleep(secs):
#     time.sleep(secs)

#下一步
def next_step():
    touch(Template(r"../next_step.png",threshold=0.6))

#我的主页入口
def sheet_entry(x,y):
    touch([0.095*x,0.95*y])
    
#冒险入口   
def risk_entry(x,y):
    touch([0.5*x,0.95*y])

#公会之家入口
def home_entry(x,y):
    touch([0.65*x,0.95*y])
    
#扭蛋入口
def egg_entry(x,y):
    touch([0.78*x,0.95*y])
    
#商店入口
def shop_entry(x,y):
    touch([0.65*x,0.8*y])

#行会入口
def guild_entry(x,y):
    touch([0.72*x,0.8*y])
    
#任务入口
def mission_entry(x,y):
    touch([0.87*x,0.8*y])

#礼物入口
def gift_entry(x,y):
    touch([0.95*x,0.8*y])
    
#判断是否在主页
def judge_sheet(x,y):
    if exists(Template(r"white_sheet.png",target_pos=2)):
        print("确实不在主页")
        touch([0.095*x,0.95*y])
        sleep(2)
    else:
        sleep(1)